package com.whfc.openapi.api.mach.service;

import com.whfc.common.result.ListData;
import com.whfc.common.result.PageData;
import com.whfc.fuum.dto.SysMachListDTO;
import com.whfc.fuum.service.SysDeptService;
import com.whfc.fuum.service.SysMachTypeService;
import com.whfc.mach.dto.*;
import com.whfc.mach.service.AppMachDataService;
import com.whfc.mach.service.AppMachService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author sun_guodong
 * @description
 * @date 2020-06-22
 */
@Service
public class OpenApiMachServiceImpl implements OpenApiMachService {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @DubboReference(interfaceClass = SysDeptService.class, version = "1.0.0")
    private SysDeptService sysDeptService;

    @DubboReference(interfaceClass = SysMachTypeService.class, version = "1.0.0")
    private SysMachTypeService sysMachTypeService;

    @DubboReference(interfaceClass = AppMachService.class, version = "1.0.0")
    private AppMachService appMachService;

    @DubboReference(interfaceClass = AppMachDataService.class, version = "1.0.0")
    private AppMachDataService appMachDataService;

    @Override
    public ListData<SysMachListDTO> typeList() {
        return sysMachTypeService.machLists(null);
    }

    @Override
    public PageData<OpenApiMachDTO> list(Integer deptId, Integer pageNum, Integer pageSize) {
        return appMachService.openApiMachList(deptId, pageNum, pageSize);
    }

    @Override
    public ListData<OpenApiMachDTO> list(Integer deptId) {
        List<OpenApiMachDTO> list = appMachService.openApiMachList(deptId);
        return new ListData<>(list);
    }

    @Override
    public OpenApiMachDTO detail(Integer machId) {
        OpenApiMachDTO openApiMachDTO = appMachService.openApiMachDetail(machId);
        return openApiMachDTO;
    }

    @Override
    public AppMachWorkHourDayDTO workHour(Integer machId, Date date) {
        return appMachDataService.getMachWorkHourDayData(machId, date);
    }

    @Override
    public OpenApiOilWearDTO oilWear(Integer machId, Date date) {
        return appMachService.openApiMachOilWear(machId, date);
    }

    @Override
    public ListData<Oil> oilPos(Integer machId, Date date) {
        return appMachDataService.oilPos(machId, date);
    }

    @Override
    public ListData<Gps> gps(Integer machId, Date date) {
        AppMachGpsDTO appMachGpsDTO = appMachDataService.gpsLog(machId, date);
        List<Gps> gpsList = appMachGpsDTO.getGpsList();
        return new ListData<>(gpsList);
    }

}
